package com.flymobi.fw.util;

import org.apache.commons.configuration.PropertiesConfiguration;

import com.flymobi.fw.exception.ConfigException;

/**
 * 
 * 
 * Title:
 * 
 * Description:
 * 
 * Copyright: Copyright (c) 2008
 * 
 * @author haoxz11
 * @created Mar 7, 2008 11:20:37 AM
 * @version $Id: Config.java,v 1.1 2008/03/26 06:24:07 airsou Exp $
 */
public class Config {

	//�����ļ����ļ��������ļ�λ��$BASE/conf��
	private static final String DEFAULT_CONF_FILE = "/baseconfig.properties";

	private static PropertiesConfiguration config = null;

	static {
		try {
			String absolutePath = Config.class.getResource(getConfigFile())
					.getFile();
			config = new PropertiesConfiguration(absolutePath);
		} catch (Exception e) {
			throw new ConfigException(e);
		}

	}
	
	
	protected static String getConfigFile(){
		return DEFAULT_CONF_FILE;
	}

	public static String getString(String key, String defaultValue) {
		return config.getString(key, defaultValue);
	}

	public static String getString(String key) {
		return config.getString(key, null);
	}

	public static int getInt(String key, int defaultValue) {
		return config.getInt(key, defaultValue);
	}

	public static int getInt(String key) {
		return config.getInt(key, 0);
	}

	public static String[] getStringArray(String key) {
		return config.getStringArray(key);
	}

	public static boolean getBoolean(String key, boolean defaultValue) {
		return config.getBoolean(key, defaultValue);
	}

	public static boolean getBoolean(String key) {
		return config.getBoolean(key, false);
	}

	public static float getFloat(String key, float defaultValue) {
		return config.getFloat(key, defaultValue);
	}

	public static float getFloat(String key) {
		return config.getFloat(key, 0);
	}
}

